* Import auctions data
clear all
global replication `c(pwd)'
global data "$replication\Data"
global inter "$replication\Dta - Intermediate"
global final "$replication\Dta - Final"
global graphs "$replication\Graphs"

import excel "$data\OutstandingsCSV.xlsx", sheet("OutstandingsCSV") firstrow clear

reshape long date_, i(ISIN) j(date)

rename date_ outstanding

tostring date, replace
gen date2=date(date, "YM")
g my=mofd(date2)
format my %tm
drop aux date date2


gen ym_date=my
rename my date

rename ISIN isin
replace isin=lower(isin)
order isin date outstanding
sort isin date
replace outstanding=0 if outstanding==.
merge m:1 ym_date using "$inter\Spain_NominalGDP.dta"
drop if _merge==2
drop _merge ym_date
gen out_ngdp=outstanding/nom_gdp
* drop outstanding nom_gdp
duplicates drop


rename date iss_my
drop if missing(iss_my)
save "$inter\Outstandings_Monthly.dta", replace




